package cardwall.client.view;

import org.puremvc.java.multicore.patterns.mediator.Mediator;
import cardwall.client.*;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.WindowResizeListener;

/**
 * @author $LastChangedBy: vogensen $
 * @version $Revision: 2 $
 */
public class ApplicationMediator extends Mediator {
    public ApplicationMediator(CardWall application) {
        super("ApplicationMediator", application);

        Window.addWindowResizeListener(new WindowResizeListener() {
            public void onWindowResized(int i, int i1) {
                sendNotification(ApplicationFacade.WINDOW_RESIZED, null, ApplicationFacade.NOTIFICATIONTYPE_DEFAULT);
            }
        });
        
        CardDetailsDialog cardDetailsDialog = new CardDetailsDialog();
        ApplicationFacade.getInstance().registerMediator(new CardDetailsDialogMediator(cardDetailsDialog));

        HeaderPanel headerPanel = new HeaderPanel();
        ApplicationFacade.getInstance().registerMediator(new HeaderPanelMediator(headerPanel));

        WallPanel wallPanel = new WallPanel();
        ApplicationFacade.getInstance().registerMediator(new WallPanelMediator(wallPanel));

        MainPanel mainPanel = new MainPanel(headerPanel, wallPanel);
        mainPanel.init();
        RootPanel.get().add(mainPanel);
    }
}